package com.frinder.official.akka.fault;

import com.frinder.official.spring.MyBaseActor;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

/**
 * Created by frinder on 2017/9/13.
 */
@Component
@Scope("prototype")
public class Child extends MyBaseActor {

    int state = 0;

    @Override
    public Receive createReceive() {
        return receiveBuilder()
                .match(Exception.class, exception -> {
                    log.debug("Exception {}", exception);
                    throw exception;
                })
                .match(Integer.class, i -> {
                    log.debug("Integer {}", i);
                    state = i;
                })
                .matchEquals("get", s -> {
                    log.debug("get {}", state);
                    getSender().tell(state, getSelf());
                })
                .build();
    }
}
